<?php
/*
 * Copyright 2009 Eat Local Food, LLC
 * Copyright (c) 2007 osCommerce (this file was written after
 * code review of osCommerce).
 *
 * This file is part of gwtCommerce.
 *
 * gwtCommerce is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * gwtCommerce is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gwtCommerce.  If not, see <http://www.gnu.org/licenses/>.
 */

class AdvancedSearchResultsComponent
{
	function AdvancedSearchResultsComponent()
	{
	}

	function action(&$params, $action)
	{
		return $this->query($params);
	}

	function query(&$params) 
	{
		$isAdministrator = (boolean)$params['isAdministrator'];

		$subParams['handle'] = 'AdvancedSearchResultsComponent';
		$subParams['languageId'] = (int)$params['languageId'];
		$subParams['productId'] = 0;
		$subParams['manufacturerId'] = (int)$params['manufacturerId'];
		$subParams['searchSpecials'] = (int)$params['searchSpecials'];
		$subParams['categoryId'] = (int)$params['categoryId'];
		$subParams['inc_subcat'] = (boolean)$params['inc_subcat'];
		$subParams['pfrom'] = (double)$params['pfrom'];
		$subParams['pto'] = (double)$params['pto'];
		$subParams['dfrom'] = (int)$params['dfrom'];
		$subParams['dto'] = (int)$params['dto'];
		$subParams['keywords'] = $params['keywords'];
		$subParams['desc_search'] = $params['desc_search'];
		$subParams['offset'] = (int)$params['offset'];
		$subParams['max_rows'] = MAX_DISPLAY_SEARCH_RESULTS;
		$subParams['orderby'] = $params['orderby'];
		$subParams['return_page_info'] = true;
		if ($isAdministrator) $subParams['include_all_status'] = true;
		
		require_once('includes/components/ProductsSearchSubComponent.php');
		$subComponent = new ProductsSearchSubComponent();
		$return = $subComponent->query($subParams);

		$return{'AdvancedSearchResultsComponentMetaData'}{'display_buy_now'}= (int)PRODUCT_LIST_BUY_NOW;
		$return{'AdvancedSearchResultsComponentMetaData'}{'display_image'}= (int)PRODUCT_LIST_IMAGE;
		$return{'AdvancedSearchResultsComponentMetaData'}{'display_manufacturer'}= (int)PRODUCT_LIST_MANUFACTURER;
		$return{'AdvancedSearchResultsComponentMetaData'}{'display_model'}= (int)PRODUCT_LIST_MODEL;
		$return{'AdvancedSearchResultsComponentMetaData'}{'display_name'}= (int)PRODUCT_LIST_NAME;
		$return{'AdvancedSearchResultsComponentMetaData'}{'display_price'}= (int)PRODUCT_LIST_PRICE;
		$return{'AdvancedSearchResultsComponentMetaData'}{'display_quantity'}= (int)PRODUCT_LIST_QUANTITY;
		$return{'AdvancedSearchResultsComponentMetaData'}{'display_weight'}= (int)PRODUCT_LIST_WEIGHT;

		return $return;
	}
}
?>
